<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>正式学员</title>
    <!-- <link type="text/css" rel="stylesheet" href="../../topjui/plugins/layui/css/layui.css"> -->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap-datetimepicker.min.css')) ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build_standalone.css')) ?>">
    <link rel="stylesheet" type="text/css" href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build.css')) ?>">
<link type="text/css" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.min.css')) ?>" rel="stylesheet"/>
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    <style>
        /*
* Base structure
*/

        /* Move down content because we have a fixed navbar that is 50px tall */
        body {
            background: #eee;
        }

        /*
         * Global add-ons
         */

        .sub-header {
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }

        /*
         * Top navigation
         * Hide default border to remove 1px line.
         */
        .navbar-fixed-top {
            border: 0;
        }

        /*
         * Sidebar
         */

        /* Hide for mobile, show later */
        .sidebar {
            display: none;
        }

        @media (min-width: 768px) {
            .sidebar {
                position: fixed;
                top: 51px;
                bottom: 0;
                left: 0;
                z-index: 1000;
                display: block;
                overflow-x: hidden;
                overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
                background-color: #f5f5f5;
                border-right: 1px solid #eee;
            }
        }

        /* Sidebar navigation */
        .nav-sidebar {
            margin-right: -21px; /* 20px padding + 1px border */
            margin-left: -20px;
        }

        .nav-sidebar > li > a {
            padding-right: 20px;
            padding-left: 20px;
        }

        .nav-sidebar > li > a span {
            float: right;
        }

        .nav-sidebar > .active > a,
        .nav-sidebar > .active > a:hover,
        .nav-sidebar > .active > a:focus {
            color: #fff;
            background-color: #428bca;
        }

        /*
         * Main content
         */

        .main .page-header {
            margin-top: 0;
        }

        .main-title {
            background: #fff;
            padding: 20px
        }

        .main-content {
            background: #fff;
            margin-top: 14px;
            padding: 20px
        }

        /*
         * Placeholder dashboard ideas
         */

        .title {
            border-bottom: 1px #eee solid;

        }

        .title button {
            float: right;
            margin-top: -12px;
        }

        .form-container {
            width: 100%;
        }

        .form-group {
            margin-top: 15px;
            margin-right: 10px;
        }

        .form-group label {
            font-weight: normal;
        }

        .form-group div input {
            width: 200px;
        }

        .nav-margin li {
            margin: 0 6px;
        }

        .dropdown-menu.menu-list {
            position: inherit;
            box-shadow: none;
            -webkit-box-shadow: none;
            width: 100%;
            border: none;
            padding-left: 10px;
            font-size: 14px;
            background: #fafafa;
        }

        .checkbox {
            display: inline-block;
        }

        label {
            font-weight: normal;
        }

        .layui-input {
            display: inline-block;
            width: inherit;
        }

        td.tdrow {
            width: 120px;
        }
    </style>
</head>
<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<div class="container-fluid">
    <div class="row">
        <form action="<?php xcho(url('/student/formal/index')) ?>" method="POST" accept-charset="utf-8"
              enctype="multipart/form-data" id="listAll">
            <div class="main">
                <div class="class-box">
                    <div class="main-title">
                        <div class="layui-tab row" lay-filter="config" lay-allowClose="true">
                            <div class="layui-tab-title">
                                <input type="hidden" id="view_id" name="view_id" value="">
                                <ul class="col-md-8"  style="display: inline-block;">
                                    <?php if(!empty($aView)) {?>
                                        <?php foreach ($aView as $aTmp) {?>
                                            <li class="layui-this" lay-id="<?php xcho($aTmp['pk'])?>" ><?php xcho($aTmp['cfg_name'])?></li>
                                        <?php }?>
                                    <?php }?>
                                </ul>
                                <div class="input-group col-md-4">

                                        <input type="text" class="form-control" placeholder="可搜索学员、联系手机" id="keyword"
                                               name="keyword" value="<?php xcho($search['keyword']) ?>">
                                        <span class="input-group-btn">
                                            <input type="submit" class="btn btn-primary edit" value="搜索" />
                                        </span>

                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-xs-6 col-sm-3 form-container">
                                <div>
                                </div>
                            </div>
                            <div class="col-xs-6 col-sm-3 form-container form-inline">
                                <div class="form-group">
                                    <label>查看范围：</label>
                                    <input style="    width: 110px;height: 34px;border: none;font-size: 12px;border: 1px #ccc solid;text-indent: 6px;"
                                           results="s" class="form-control group-picker" id="scale_name" name="scale_name"
                                           type="search" value="<?php xcho($search['scale_name']) ?>"
                                           url="<?php xcho($sSearchRange) ?>">
                                    <input results="s" id="scale_type" name="scale_type" type="hidden"
                                           value="<?php xcho($search['scale_type']) ?>">
                                    <input results="s" id="scale_id" name="scale_id" type="hidden"
                                           value="<?php xcho($search['scale_id']) ?>">
                                </div>
                                <div class="form-group">
                                    <label>修改日期：</label>
                                    <select name="datetp" class="form-control">
                                        <option value="">全部</option>
                                        <?php foreach ($dateType as $dk => $dV) { ?>
                                            <option value="<?php xcho($dV['dict_value']) ?>" <?php if ($search['datetp'] == $dV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($dV['cn_name']) ?></option>
                                        <?php } ?>
                                    </select>
                                    <input size="16"
                                           type="text"  value="<?php xcho($search['begin_edit_time']) ?>"
                                           name="begin_edit_time" class="form-control begin_edit_time"
                                           placeholder="yy-mm-dd">

                                    <input size="16" type="text"  value="<?php xcho($search['end_edit_time']) ?>" name="end_edit_time" class="form-control end_edit_time" placeholder="yy-mm-dd">
                                </div>
                                <div class="form-group">
                                    <label>转化日期：</label>
                                    <select name="change_time" class="form-control">
                                        <option value="">全部</option>
                                        <?php foreach ($dateType as $ak => $aV) { ?>
                                            <option value="<?php xcho($aV['dict_value']) ?>" <?php if ($search['change_time'] == $aV['dict_value']) { ?> selected="selected"<?php } ?> > <?php xcho($aV['cn_name']) ?></option>
                                        <?php } ?>
                                    </select>
                                    <input size="26" type="text"  value="<?php xcho($search['begin_change_time']) ?>" name="begin_change_time" class="form-control begin_change_time" placeholder="yy-mm-dd">
                                    <input size="26" type="text"  value="<?php xcho($search['end_change_time']) ?>" name="end_change_time" class="form-control end_change_time" placeholder="yy-mm-dd">
                                    <input type="submit" class="btn btn-primary edit" value="搜索" />
                                </div>
                            </div>
                            <div class="col-xs-6 col-sm-3 form-container form-inline">
                                <div >
                                    <?php if(!empty($channel)){ ?>
                                    <a href="#" id="toggle">渠道展开</a>
                                    <div id="content" style="display: none;">
                                        <label>渠道：</label>
                                        <label>全选：<input type="checkbox" id="channelAll"></label>
                                        <div class="checkbox_channel">
                                            <?php foreach ($channel as  $cV) { ?>
                                                <label class="checkbox-inline">
                                                    <input type="checkbox" title="checkbox_channel"
                                                           name="channel_id[]" <?php if (!empty($search['channel_id'])) {
                                                        foreach ($search['channel_id'] as $in) {
                                                            if ($in == $cV['id']) { ?> checked="checked" <?php }
                                                        }
                                                    } ?>
                                                           value="<?php xcho($cV['id']) ?>"></input><?php xcho($cV['cn_name']) ?>
                                                </label>
                                            <?php } ?>
                                        </div>
                                    </div>
                                    <?php } ?>
                                </div>

                                <div class="form-group">
                                    <label>学员状态：</label>
                                    <select name="is_test" class="form-control">
                                        <option value="">全部</option>
                                        <?php foreach ($stu_type as $is) { ?>
                                            <option value="<?php xcho($is['dict_value']) ?>" <?php if ($search['is_test'] == $is['dict_value']) { ?>  selected="selected" <?php } ?> > <?php xcho($is['cn_name']) ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                </div>
                                <div class="col-xs-6 col-sm-3 form-container form-inline">

                            </div>
                            <div class="btns-group">
                                <a href="javascript:;" class="btn btn-white" id="save_config">保存设置</a>
                                <a href="javascript:;" class="btn btn-primary" id="save_recover">恢复默认</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="class-box">
                    <div class="class-box-head">
                        <div class="class-box-title">
                            <h3>正式学员列表</h3>
                            <div class="class-box-tools">
<!--                               <span class="btn btn-primary stu_export">导出</span>-->
                            </div>
                        </div>
                        <div class="from-top row">
                            <div class="from-top-left col-md-5">
                                <ul>
                                    <?php if (!empty($aActions['edit_tmk'])) { ?>
                                        <li>
<!--                                            <button type="button" class="btn btn-primary" id="tmk">分配TMK</button>-->
                                        </li>
                                    <?php } ?>
                                    <?php if (!empty($aActions['edit_cc'])) { ?>
                                        <li>
<!--                                            <button type="button" id="cc" class="btn btn-primary">分配CC</button>-->
                                        </li>
                                    <?php } ?>
                                    <?php if (!empty($aActions['edit_cr'])) { ?>
                                        <li>
                                            <button type="button" id="cr" class="btn btn-primary">分配CR</button>
                                        </li>
                                    <?php } ?>
                                    <li class="dropdown">
                                        <button type="button" class="btn btn-warning dropdown-toggle"
                                                data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                                                aria-expanded="false">更多操作 <span class="caret"></span></button>
                                        <ul class="dropdown-menu">
                                            <?php if (!empty($aActions['edits'])) { ?>
                                                <li><a href="#" id="updates">批量修改</a></li>
                                            <?php } ?>
                                            <?php if (!empty($aActions['dels'])) { ?>
                                                <li><a href="#" id="dels" class="delete">批量删除</a></li>
                                            <?php } ?>
                                        </ul>
                                    </li>

                                </ul>
                            </div>
                        </div>
                    </div>

                    <form method="post" action="<?php xcho(url('/student/formal/index')) ?>">
                        <div class="row pagination-wrap">
                            <div class="col-sm-6">
                                <div class="pagination-group col-sm-12">
                                    <input class="form-control" type="number" min="1" max="<?php xcho($maxPage) ?>"
                                       name="pagelist" placeholder="请输入页码" value="<?php xcho($nowPage) ?>"/>
                                    <input class="btn btn-primary" type="submit" value="确定"/>
                                    <span>共搜索到<?php xcho($totalNum) ?>条记录</span>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <ul class="pagination">
                                    <?php xchoHtml($page->render()) ?>
                                </ul>
                            </div>
                        </div>
                    </form>
                        
                    <div class="class-box-body">
                        <table class="layui-form table table-bordered table-hover table table-bordered table-striped table-fixed">
                            <thead>
                            <tr>
                                <th>
                                    <div id="checkAll"><input lay-filter="allChoose" type="checkbox" lay-skin="primary" name="checkAll"></div>
                                </th>
                                <th>名称</th>
                                <th>联系手机</th>
                                <th>学校</th>
                                <th>地区</th>
                                <th>年级</th>
                                <th style="cursor: pointer;">
                                    <a style="position: relative;"  href="javascript:;">
                                        最新跟踪时间
                                        <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['last_follow_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['last_follow_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                                </th>
                                <th width="150px">最新跟踪记录</th>
                                <th width="150px">最新跟踪人</th>
                                <th>CC负责人</th>
                                <th>学员状态</th>
                                <th style="cursor: pointer;">
                                    <a style="position: relative;"  href="javascript:;">
                                        转化时间
                                        <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['change_time_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['change_time_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                                </th>
                                <th style="cursor: pointer;">
                                    <a style="position: relative;"  href="javascript:;">
                                        CR负责人
                                        <span style="position: absolute; top:-6px" ><a href="<?php xcho($order_by_field['cr_id_asc']) ?>"><i class="upOrder glyphicon glyphicon-triangle-top" style="display:"></i></a>
                                           <a href="<?php xcho($order_by_field['cr_id_desc']) ?>"><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:
                                       "></i></a>
                                    </span>
                                </th>
                                <th width="120px">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($list as $vo) { ?>
                                <tr>
                                    <td>
                                        <input lay-filter="itemChoose" value="<?php xcho($vo['id']) ?>" type="checkbox"
                                               name="ck" lay-skin="primary">
                                    </td>
                                    <td>
                                        <a href="<?php xcho(url('student/formal/studentinfo')) ?>?student_id=<?php xcho($vo['id']) ?>" target="_blank"><?php xcho($vo['sname']) ?></a>
                                    </td>
                                    <td><?php xcho($vo['cellphone']) ?></td>
                                    <td><?php xcho($vo['school']) ?></td>
                                    <td><?php xcho($vo['area']) ?></td>
                                    <td><?php xcho($vo['grade_name']) ?></td>
                                    <td><?php xcho($vo['new_add_time']) ?></td>
                                    <td><?php xcho($vo['new_follow_remark']) ?></td>
                                    <td><?php xcho($vo['new_opeator']) ?></td>
                                    <td><?php xcho($vo['cc_name']) ?></td>
                                    <td><?php xcho($vo['is_test']) ?></td>
                                    <td>
                                        <?php if(!empty($vo['change_time'])){ ?>
                                        <?php xcho($vo['change_time']) ?>
                                        <?php } ?>
                                    </td>
                                    <td><?php xcho($vo['cr_name']) ?></td>
                                    <td class="tdrow">
                                        <?php if (!empty($aActions['edit'])) { ?>
                                            <button data-cn_id="<?php xcho($vo['id']) ?>" type="button"
                                                    class="btn btn-primary edit"
                                                    user_id="<?php xcho($vo['id']) ?>"><a
                                                        style="display: block;color: #ffffff"
                                                        href="<?php xcho($editstudent) ?>?student_id=<?php xcho($vo['id']) ?>">编辑</a>
                                            </button>
                                        <?php } ?>
                                        <?php if (!empty($aActions['del'])) { ?>
                                            <button data-cn_id="<?php xcho($vo['id']) ?>" type="button"
                                                    class="btn btn-sub delete">删除
                                            </button>
                                        <?php } ?>

                                    </td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="tmk-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="modal-body ztree" id="tmklist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="suretmk" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="cc-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="modal-body ztree" id="cclist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="surecc" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="cr-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="modal-body ztree" id="crlist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="surecr" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<div id="modalbox"></div>
<div class="modal fade" id="info-modal-group" tabindex="-1" role="dialog" aria-labelledby="modal-info-label">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-info">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>
            </div>
            <div class="modal-body" style="min-height: 150px;">
                <div class="form-group">
                    <input class="form-control" id="treeDemoinput" type="text">
                </div>
                <ul id="treeDemo" class="ztree">
                </ul>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="sureGroup" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>
            </div>
        </div>
    </div>
</div>
<div id="updatebox" style="display: none">
    <select name="quickedit_field" class="small" style="width: 100%" onchange="quick_edit_fieldchange(this)">
        <option>请选择</option>
        <option value="sname" relvalue="1">学员姓名</option>
        <option value="cellphone" relvalue="1">联系手机</option>
        <option value="telephone" relvalue="15">家庭座机</option>
        <option value="sex" relvalue="1">性别</option>
        <option value="age" relvalue="1">年龄</option>
        <option value="wechat" relvalue="1">微信</option>
        <option value="qq" relvalue="1">QQ</option>
        <option value="email" relvalue="1">邮箱</option>
        <option value="channel_id" relvalue="15">渠道来源</option>
        <option value="province" relvalue="11">省</option>
        <option value="city" relvalue="5">市</option>
        <option value="county" relvalue="1">区县</option>
        <option value="home_address" relvalue="1">家庭地址</option>
        <option value="admission_time" relvalue="15">入学时间</option>
        <option value="school" relvalue="15">当前学校</option>
        <option value="grade" relvalue="5">年级</option>
        <option value="intention" relvalue="1">意向状态</option>
        <option value="is_test" relvalue="1021">是否测试</option>
        <option value="is_treasure" relvalue="1022">是否丢入藏经阁</option>
        <option value="creator_id" relvalue="86">创建人id</option>
        <option value="twx_id" relvalue="1033">天王星学员id</option>
        <option value="gw_id" relvalue="1">官网学员id</option>
        <option value="gw_password" relvalue="1">官网学员密码</option>
        <option value="tmk_id" relvalue="15">TMKID</option>
        <option value="cc_id" relvalue="15">CCID</option>
    </select>
    <div class="up_area" style="width: 100%;margin-top: 20px;">
        <div id="quickedit_field0" style="display: none;">&nbsp;</div>
        <div id="quickedit_field_sname" uitype="1" style="display: none;">
            <input type="text" tabindex="1" name="quickedit_value_sname" id="sname" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_cellphone" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_cellphone" id="cellphone" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_telephone" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_telephone" id="telephone" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_sex" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_sex" id="sex" tabindex="511111" class="small">
                <option value="无">
                    无
                </option>
                <option value="male">
                    男
                </option>
                <option value="female">
                    女
                </option>
            </select>
        </div>
        <div id="quickedit_field_age" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_age" id="age" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_wechat" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_wechat" id="wechat" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_qq" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_qq" id="qq" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_email" uitype="1" style="display: none;">
            <input type="text" tabindex="12" name="quickedit_value_email" id="email" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_channel_id" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_channel_id" id="channel_id" tabindex="211111" class="small">
                <?php foreach ($channel as $cV) { ?>
                    <option value="<?php xcho($cV['id']) ?>" <?php if ($search['channel_id'] == $cV['id']) { ?>  selected="selected" <?php } ?> > <?php xcho($cV['cn_name']) ?></option>
                <?php } ?>
            </select>
        </div>
        <div id="quickedit_field_province" uitype="1" style="display: none;">
            <input type="text" tabindex="13" name="quickedit_value_province" id="province" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_city" uitype="1" style="display: none;">
            <input type="text" tabindex="3" name="quickedit_value_city" id="city" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_county" uitype="1" style="display: none;">
            <input type="text" tabindex="14" name="quickedit_value_county" id="county" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_home_address" uitype="1" style="display: none;">
            <input type="text" tabindex="4" name="quickedit_value_home_address" id="home_address" value=""
                   class="detailedViewTextBox">


        </div>
        <div id="quickedit_field_admission_time" uitype="1" style="display: none;">
            <input type="text" tabindex="15" name="quickedit_value_admission_time" id="admission_time" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_school" uitype="11" style="display: none;">
            <input type="text" tabindex="16" name="quickedit_value_school" id="school" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_grade" uitype="5" style="display: none;">

            <input name="quickedit_value_grade" tabindex="6" id="jscal_field_grade" type="text"
                   style="border:1px solid #bababa;" size="11" maxlength="10" value="">
            <i class="icon-calendar pure-icon-bu crm-bu-style" onclick="displayCalendar('jscal_field_cf_865',this);"
               style="width:50px;height:50px;cursor:pointer;font-size:14px">
            </i>
        </div>
        <div id="quickedit_field_intention" uitype="1" style="display: none;">
            <input type="text" tabindex="17" name="quickedit_value_intention" id="intention" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_is_test" uitype="1" style="display: none;">
            <input type="text" tabindex="7" name="quickedit_value_is_test" id="is_test" value=""
                   class="detailedViewTextBox">
        </div>
        <div id="quickedit_field_is_treasure" uitype="15" style="display: none;">
            <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
            <select name="quickedit_value_is_treasure" id="is_treasure" tabindex="1811111" class="small">
                <option value="no">
                    否
                </option>
                <option value="yes">
                    是
                </option>
            </select>
        </div>
        <div id="quickedit_field_creator_id" uitype="5" style="display: none;">
            <input name="quickedit_value_creator_id" tabindex="19" id="creator_id" type="text">
        </div>
        <div id="quickedit_field_twx_id" uitype="5" style="display: none;">
            <input name="quickedit_value_twx_id" tabindex="19" id="twx_id" type="text">
        </div>
        <div id="quickedit_field_gw_id" uitype="5" style="display: none;">
            <input name="quickedit_value_gw_id" tabindex="19" id="gw_id" type="text">
        </div>
        <div id="quickedit_field_tmk_id" uitype="5" style="display: none;">
            <input name="quickedit_value_tmk_id" tabindex="19" id="tmk_id" type="text">
        </div>
        <div id="quickedit_field_cc_id" uitype="5" style="display: none;">
            <input name="quickedit_value_cc_id" tabindex="19" id="cc_id" type="text">
        </div>
    </div>
</div>
<div class="modal fade" id="config-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>自定义快捷视图</h4>
            </div>
            <div class="modal-body layui-form" style="min-height: 150px;">
                <?php if(isset($aActions['config']) && $aActions['config'] == 'Y') {?>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否公用</label>
                        <div class="layui-input-block">
                            <select id="is_public" name="is_public" lay-verify="required">
                                <?php foreach ($aConfirm as $aTmp) { ?>
                                    <option value="<?php xcho($aTmp['dict_value']) ?>"><?php xcho($aTmp['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                <?php }?>
                <div class="layui-form-item">
                    <label class="layui-form-label">快捷视图标题</label>
                    <div class="layui-input-block">
                        <input type="text" id="cfg_name" name="cfg_name" required
                               lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        <input type="hidden" id="module" name="module" value="<?php xcho($sControllerModule)?>">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <span type="button" class="btn btn-primary" id="sureConfig" data-dismiss="modal" url="<?php xcho($saveConfig)?>">保存</span>
                <span type="button" class="btn btn-default" data-dismiss="modal">关闭</span>
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="del" value="<?php xcho($del) ?>"/>
<input type="hidden" name="dels" value="<?php xcho($dels) ?>"/>
<input type="hidden" name="groupList" value="<?php xcho($groupList) ?>">
<input type="hidden" name="tmklist" value="<?php xcho($tmkList) ?>">
<input type="hidden" name="cclist" value="<?php xcho($ccList) ?>">
<input type="hidden" name="editTMK" value="<?php xcho($editTMK) ?>">
<input type="hidden" name="editCC" value="<?php xcho($editCC) ?>">
<input type="hidden" name="edit_student" value="<?php xcho($editstudent) ?>"/>
<input type="hidden" name="batch_student" value="<?php xcho($batchStudent) ?>"/>
<input type="hidden" name="stuExport" value="<?php xcho($stuExport) ?>"/>
<input type="hidden" name="crlist" value="<?php xcho($crList) ?>">
<input type="hidden" name="editCR" value="<?php xcho($editCR) ?>">
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.fr.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap-datetimepicker.zh-CN.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>

    $(function(){


        $("#toggle").click(function() {
            $(this).text($("#content").is(":hidden") ? "渠道收起" : "渠道展开");
            $("#content").slideToggle();
        });

        $("#top").click(function() {
            $("html,body").animate({scrollTop:0}, 500);
        });
        layui.use(['layer', 'form'], function () {
            var element = layui.element;
            //监听Tab切换，以改变地址hash值
            element.on('tab(config)', function () {
                $("#view_id").val(this.getAttribute('lay-id'));
                var view_all = $("#view_id").val();
                if(view_all == "nomal"){
                    $("#listAll").find('input[type=text],select,input[type=hidden],input[type=checkbox]').each(function(){
                      $(this).val('');
                    });
                }
                $("input[type='submit']").click();
            });
        });

        $("#channelAll").click(function(){
            var ischecked = $(this).is(':checked');
            var child = $(".checkbox_channel").find('input[type=checkbox]');
            child.each(function(index, item){
                item.checked = ischecked;
            });
        });

    })
    $(".layui-tab-close").on('click',function () {
        $.ajax({
            url: "<?php xcho($sDelView)?>",
            data: {
                id: $(this).parent().attr('lay-id')
            },
            type: 'post',
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    layer.alert("删除成功!")
                } else {
                    alert(data.msg);
                }
            },
            complete: function () {
                location.reload();
            },
            error: function () {

            }
        });
    });

    //显示保存快捷视图
    $("#save_config").on("click", function () {

        $('#config-modal').modal({
            keyboard: false,
            backdrop: false
        });
        $("#select-picker").focus(function () {
            $('#config-modal').modal({
                keyboard: false,
                backdrop: false
            });
        });
    })

    //保存视图
    $("#sureConfig").on("click", function () {
        var ids = [];
        $('.checkbox').find("input[type='checkbox']:checked").each(function () {
            ids.push($(this).val());
        });
        var channelids=[];
        $('.checkbox_channel').find("input[title='checkbox_channel']:checked").each(function () {
            channelids.push($(this).val());
        });
        var aArrData = new Array();
        aArrData = {
            'is_public':$("#is_public").val(),
            'cfg_name':$("#cfg_name").val(),
            'module':$("#module").val(),
            'cfg_value':{
                'scale_name':$("#scale_name").val(),
                'scale_type':$("#scale_type").val(),
                'scale_id':$("#scale_id").val(),
                'intention':ids,
                'datetp':$("[name='datetp']").val(),
                'change_time':$("[name='change_time']").val(),
                'channel_id':channelids,
                'is_follow':$("[name='is_follow']").val(),
                'last_follow_id':$("[name='last_follow_id']").val(),
//                'next_contact_time':$("[name='next_contact_time']").val(),
                'keyword':$("[name='keyword']").val(),
                'is_test':$("[name='is_test']").val(),
            }
        };
        $.ajax({
            url: $("#sureConfig").attr('url'),
            type: 'post',
            data: aArrData,
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    location.reload();
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
    })

    //恢复默认视图
    $("#save_recover").on("click", function () {
        var aArrData = new Array();

        $.ajax({
            url: "<?php xcho($sRestoreView)?>",
            type: 'post',
            data: {
                'module':$("#module").val(),
            },
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    location.reload();
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
    })
    var select_option, select_element;
    function quick_edit_fieldchange(element) {

        var e = "#quickedit_field_" + element.value;
        //console.log($(e).html());
        $("div[id*='quickedit_field_']").css("display", "none");
        $("#LAY_layuipro").find(e).fadeIn();
        select_option = element.value;
        select_element = e
    }
//    (function ($) {
        var layer = layui.layer
            , form = layui.form, laydate = layui.laydate;
        //全选
        $('input[name="checkAll"]').click(function () {
            //alert(this.checked);
            if ($(this).is(':checked')) {
                $('input[name="ck"]').each(function () {
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked", true);
                });
            } else {
                $('input[name="ck"]').each(function () {
                    $(this).removeAttr("checked", false);
                });
            }
        });
        //日历
        $(".begin_edit_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_edit_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".begin_add_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_add_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".begin_last_follow_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_last_follow_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".begin_next_contact_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".end_next_contact_time").datetimepicker({
            format: "yyyy-mm-dd",
            todayHighlight: true,
            autoclose: true,
            language: 'zh-CN',
            startView: 2,
            minView: 2,
            maxView: 2
        });
        $(".form-group>select").change(function () {
            var dataVal = $(this).val();
            var aDataInfo = getDates(dataVal);
            var sClassInfo = $(this).attr('name');
            if (sClassInfo == 'datetp') {
                $('.begin_edit_time').val(aDataInfo['sStartDate']);
                $('.end_edit_time').val(aDataInfo['sEndDate']);
            }
            if (sClassInfo == 'change_time') {
                $('.begin_change_time').val(aDataInfo['sStartDate']);
                $('.end_change_time').val(aDataInfo['sEndDate']);
            }
            if (sClassInfo == 'next_contact_time') {
                $('.begin_next_contact_time').val(aDataInfo['sStartDate']);
                $('.end_next_contact_time').val(aDataInfo['sEndDate']);
            }
            if (sClassInfo == 'last_follow_id') {
                $('.begin_last_follow_time').val(aDataInfo['sStartDate']);
                $('.end_last_follow_time').val(aDataInfo['sEndDate']);
            }

        });
//        $(".form-group>select").change(function(){
//            var dataVal = $(this).val();
//            if(dataVal == 'define'){
//                $(this).siblings("input").attr('disabled',false);
//            }else{
//                $(this).siblings("input").attr('disabled',true);
//                $(this).siblings("input").val("");
//                $(this).siblings("input").attr('placeholder','yy-mm-dd');
//            }
//        });

        var layer = layui.layer
            , form = layui.form, laydate = layui.laydate;
        //全选
        layui.form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

        $(".top_more").hover(function () {
            $(this).find("ul").show();
        }, function () {
            $(this).find("ul").hide();
        });
        $("#dels").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                $.ajax({
                    url: $("input[name='dels']").val(),
                    data: {
                        ids: ids
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.success == 1) {
                            layer.alert("删除成功！", function () {
                                location.reload();
                            });
                        } else {

                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            }

        });
        $("#pool").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                $.ajax({
                    url: $("input[name='isTreasure']").val(),
                    data: {
                        ids: ids
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.success == 1) {
                            layer.alert("操作成功！", function () {
                                location.reload();
                            });
                        } else {

                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            }

        });
        $("#updates").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                layer.open({
                    type: 1
                    , title: false //不显示标题栏
                    , closeBtn: false
                    , area: '300px;'
                    , shade: 0.8
                    , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    , btn: ['保存', '取消']
                    , moveType: 1 //拖拽模式，0或者1
                    , content: '<div style="padding: 50px; line-height: 22px;  font-weight: 300;">' +
                    $("#updatebox").html() +
                    '</div>'
                    , success: function (layero) {
                        var select_data = {};
                        var btn = layero.find('.layui-layer-btn');
                        btn.css('text-align', 'center');
                        btn.find('.layui-layer-btn0').on("click", function () {
                            console.log("#" + select_option)
                            var a = ".layui-layer-content #" + select_option;
                            select_data[select_option] = $(a).val()
                            $.ajax({
                                url: $("input[name='batch_student']").val(),
                                data: {
                                    ids: ids,
                                    data: select_data
                                },
                                type: 'post',
                                dataType: 'json',
                                success: function (data) {
                                    if (data.success == 1) {
                                        layer.alert("修改成功！", function () {
                                            location.reload();
                                        });
                                    } else {

                                    }
                                },
                                complete: function () {
                                },
                                error: function () {

                                }
                            });
                        })
                    }
                });
            }

        });
        $("#tmk").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                    ' <div class="modal-dialog" role="document">' +
                    ' <div class="modal-content">' +
                    '<div class="modal-header state modal-info">' +
                    '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                    '</button>' +
                    '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                    '</div>' +
                    ' <div class="modal-body" style="min-height: 150px;">' +
                    '<div class="col-xs-12">' +
                    ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">TMK:</label>' +
                    '<div class="col-sm-9">' +
                    '<input class="form-control" data-tmk-id="" id="select-picker" name="select-picker" type="text" placeholder="TMK">' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '<div class="modal-footer">' +
                    '<button type="button" class="btn btn-info" id="surepass" data-dismiss="modal">保存</button>' +
                    '<button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
                $("#modalbox").html("").html(modal);
                $('#data-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
                $("#select-picker").focus(function () {
                    $('#tmk-modal').modal({
                        keyboard: false,
                        backdrop: false
                    });
                });
                $("#suretmk").on("click", function () {
                    var zTree = $.fn.zTree.getZTreeObj("tmklist"),
                        nodes = zTree.getSelectedNodes(),
                        treeNode = nodes[0];
                    if (nodes.length == 0) {
                        alert("请先选择一个节点");
                        return;
                    }
                    $("#select-picker").val(treeNode.name).attr("data-tmk-id", treeNode.id);
                })
                $("#surepass").on("click", function () {
                    $.ajax({
                        url: $("input[name='editTMK']").val(),
                        type: 'post',
                        data: {
                            student_ids: ids,
                            tmk_id: $("input[name='select-picker']").attr("data-tmk-id")
                        },
                        dataType: 'json',
                        success: function (data) {
                            if (data.success == 1) {
                                location.reload();
                            } else {
                            }
                        },
                        complete: function () {
                        },
                        error: function () {

                        }
                    });
                })
            }
        })
        $("#cc").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                    ' <div class="modal-dialog" role="document">' +
                    ' <div class="modal-content">' +
                    '<div class="modal-header state modal-info">' +
                    '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                    '</button>' +
                    '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                    '</div>' +
                    ' <div class="modal-body" style="min-height: 150px;">' +
                    '<div class="col-xs-12">' +
                    ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">CC:</label>' +
                    '<div class="col-sm-9">' +
                    '<input class="form-control" id="select-picker" name="select-picker" type="text" placeholder="CC">' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '<div class="modal-footer">' +
                    '<button type="button" class="btn btn-info" id="savecc" data-dismiss="modal">保存</button>' +
                    '<button type="button" class="btn btn-default" id="returncc" data-dismiss="modal">返回</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
                $("#modalbox").html("").html(modal);
                $('#data-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
                $("#select-picker").focus(function () {
                    $('#cc-modal').modal({
                        keyboard: false,
                        backdrop: false
                    });
                });
                $("#surecc").on("click", function () {
                    var zTree = $.fn.zTree.getZTreeObj("cclist"),
                        nodes = zTree.getSelectedNodes(),
                        treeNode = nodes[0];
                    console.log(treeNode);
                    if (nodes.length == 0) {
                        alert("请先选择一个节点");
                        return;
                    }
                    $("#select-picker").val(treeNode.name).attr("data-cc-id", treeNode.id);
                })
                $("#savecc").on("click", function () {
                    console.log($("input[name='editCC']").val())
                    $.ajax({
                        url: $("input[name='editCC']").val(),
                        type: 'post',
                        data: {
                            student_ids: ids,
                            cc_id: $("input[name='select-picker']").attr("data-cc-id")
                        },
                        dataType: 'json',
                        success: function (data) {
                            if (data.success == 1) {
                                location.reload();
                            } else {
                            }
                        },
                        complete: function () {
                        },
                        error: function () {

                        }
                    });
                })
            }
        })



        $("#cr").on("click", function () {
            var ids = [];
            $('input[name="ck"]:checked').each(function () {
                ids.push($(this).val());
            });
            if (ids.length == 0) {
                layer.alert("至少选择一项");
            } else {
                var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                    ' <div class="modal-dialog" role="document">' +
                    ' <div class="modal-content">' +
                    '<div class="modal-header state modal-info">' +
                    '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                    '</button>' +
                    '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                    '</div>' +
                    ' <div class="modal-body" style="min-height: 150px;">' +
                    '<div class="col-xs-12">' +
                    ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">CR:</label>' +
                    '<div class="col-sm-9">' +
                    '<input class="form-control" data-cr-id="" id="select-picker" name="select-picker" type="text" placeholder="CR">' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '<div class="modal-footer">' +
                    '<button type="button" class="btn btn-info" id="surepasscr" data-dismiss="modal">保存</button>' +
                    '<button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>' +
                    '</div>' +
                    '</div>' +
                    '</div>' +
                    '</div>';
                $("#modalbox").html("").html(modal);
                $('#data-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
                $("#select-picker").focus(function () {
                    $('#cr-modal').modal({
                        keyboard: false,
                        backdrop: false
                    });
                });
                $("#surecr").on("click", function () {
                    var zTree = $.fn.zTree.getZTreeObj("crlist"),
                        nodes = zTree.getSelectedNodes(),
                        treeNode = nodes[0];
                    if (nodes.length == 0) {
                        alert("请先选择一个节点");
                        return;
                    }

                    $("#select-picker").val(treeNode.name).attr("data-cr-id", treeNode.id);
                })
                $("#surepasscr").on("click", function () {
                    $.ajax({
                        url: $("input[name='editCR']").val(),
                        type: 'post',
                        data: {
                            student_ids: ids,
                            cr_id: $("input[name='select-picker']").attr("data-cr-id")
                        },
                        dataType: 'json',
                        success: function (data) {
                            if (data.success == 1) {
                                location.reload();
                            } else {
                            }
                        },
                        complete: function () {
                        },
                        error: function () {

                        }
                    });
                })
            }
        })



        $("#add").on("click", function () {
            var url = $("input[name='add_student']").val();
            window.location.href = url;
            //window.parent.addParentTab({href: $("input[name='add_student']").val(), title: '添加学员'})
        })



        $(".delete").on("click", function () {
            if (confirm("确定删除本条数据吗？")) {
                var cn_id = $(this).attr("data-cn_id");
                $.ajax({
                    url: $("input[name='del']").val(),
                    data: {
                        ids: cn_id
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.success == 1) {
                            layer.alert("删除成功!", {
                                skin: 'layui-layer-molv'
                            }, function () {
                                location.reload();
                            })
                        } else {
                            layer.alert(data.msg, {
                                skin: 'layui-layer-molv'
                            }, function () {
                                location.reload();
                            })
                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            }
        })


    function getCrListData() {
        var data_list;
        $.ajax({
            url: $("input[name='crlist']").val(),
            type: 'post',
            async: false,
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    data_list = data.data_list;
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
        return data_list;
    }
        function getTmkListData() {
            var data_list;
            $.ajax({
                url: $("input[name='tmklist']").val(),
                type: 'post',
                async: false,
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        data_list = data.data_list;
                    } else {
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
            return data_list;
        }

        function getCcListData() {
            var data_list;
            $.ajax({
                url: $("input[name='cclist']").val(),
                type: 'post',
                async: false,
                dataType: 'json',
                success: function (data) {
                    if (data.success == 1) {
                        data_list = data.data_list;
                    } else {
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
            return data_list;
        }



        $(".group-picker").focus(function () {
            $('#info-modal-group').modal({
                keyboard: false,
                backdrop: false
            });
            $('#info-modal-group').on('shown.bs.modal', function (e) {
                // 关键代码，如没将modal设置为 block，则$modala_dialog.height() 为零
                $(this).css('display', 'block');
                $(this).find('.modal-dialog').css({
                    'margin-top': "100px"
                });
            });
        });
        //查看范围
        var setting = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            },
            callback: {
                beforeDrag: beforeDrag,
//                beforeRemove: beforeRemove,
//          beforeRename: beforeRename,
//                onRemove: onRemove,
                onClick: zTreeOnClick
            }
        };
        var settingGroup = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            }
        };
        var log, className = "dark";

        function beforeDrag(treeId, treeNodes) {
            return false;
        }

        //选中赋值到input中
        function zTreeOnClick(event, treeId, treeNode) {
            $(".group-picker").val(treeNode.name);
            $("#scale_type").val(treeNode.scale_type);
            $("#scale_id").val(treeNode.id);
        }

        $(document).ready(function () {
            onLoadZTree();
        });
        function onLoadZTree() {
            var treeNodes;
            $.ajax({
                url: $(".group-picker").attr('url'),
                type: 'get',
                async: false,
                dataType: 'json',
                success: function (data) {
                    treeNodes = data.data_list.aGroup;//把后台封装好的简单Json格式赋给treeNodes
                    var t = $("#treeDemo");
                    $.fn.zTree.init(t, setting, treeNodes);
                    $('#treeDemoinput').on('input', function(){
                        // 过滤数组
                        var _filterList = getCurIndex(treeNodes, 'name', $(this).val())
                        $.fn.zTree.init(t, setting, _filterList);
                    })
                }
            });
            // var t = $("#treeDemo");
            // t = $.fn.zTree.init(t, setting, treeNodes);
        }

        $("form").submit(function (e) {
            //alert("Submitted");
        });
        var settingTmk = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            }
        };
        var zNodesTmk = getTmkListData();
        $.each(zNodesTmk, function (i, item) {
//            item.isParent = true;
            item.name = item.full_name
//            item.Pid = item.id
        })
        $.fn.zTree.init($("#tmklist"), settingTmk, zNodesTmk);
        var settingCc = {
            view: {
                selectedMulti: false
            },
            edit: {
                enable: false
            },
            data: {
                keep: {
                    parent: true,
                    leaf: true
                },
                simpleData: {
                    enable: true
                }
            }
        };
        var zNodesCc = getCcListData();
        $.each(zNodesCc, function (i, item) {
//            item.isParent = true;
            item.name = item.full_name
        })
        $.fn.zTree.init($("#cclist"), settingCc, zNodesCc);


//    })(jQuery);


    var settingCr = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var zNodesCr = getCrListData();
    $.each(zNodesCr, function (i, item) {
        item.name = item.full_name
    })
    $.fn.zTree.init($("#crlist"), settingCr, zNodesCr);


    $('.stu_export').click(function () {
        var aIds = [];
        $("input[name='ck']:checked").each(function () {
            aIds.push($(this).val());
        });
        if (aIds == '' || aIds.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var url = $("input[name='stuExport']").val();
            $.ajax({
                url: url,
                type: 'post',
                dataType: 'json',
                data: {ids: aIds},
                success: function (resp) {
                    if (resp.success == 1) {
                        window.open(resp.data);
                    } else {
                        layer.alert("导出失败");
                    }
                },
                complete: function () {
                },
                error: function () {

                }
            });
        }

    });

    $(function () {
        $(".daoru").click(function () {
            var url = $("input[name='stuImport']").val();
            var formdata = new FormData();
            formdata.append("stu_import", $('input[name=stu_import]')[0].files[0]);
            $.ajax({
                type: "POST",
                url: url,
                data: formdata,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (resp) {
                    if (resp.success == 1) {
                        alert('总数:' + resp.num.total + ',成功:' + resp.num.success + ',失败：' + resp.num.failed + ',激活' + resp.num.active);
                        window.location.reload();
                    } else {
                        alert(resp.msg);
                        window.location.reload();
                    }
                },
            });
        })
    })


    function getDates(sDateType) {
        var aDate = new Array();
        aDate['sStartDate'] = '';
        aDate['sEndDate'] = '';
        switch (sDateType) {
            case 'month':
                aDate['sStartDate'] = '<?php $BeginDate = date("Y-m-01", strtotime(date("Y-m-d"))); xcho($BeginDate)?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("$BeginDate +1 month -1 day")))?>';
                break;
            case 'sevenday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-7 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'thirtyday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-30 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'today':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d"))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d"))?>';
                break;
            case 'week':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("this week")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("this week +6 day")))?>';
                break;
            case 'yesterday':
                aDate['sStartDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("-1 days")))?>';
                break;
            default:

                break;
        }
        return aDate;
    }

</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>
</html>
